var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(e, t) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(e, t) {
        e.__proto__ = t;
    } || function(e, t) {
        for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
    })(e, t);
}, function(e, t) {
    function n() {
        this.constructor = e;
    }
    o(e, t), e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, 
    new n());
}), a = this && this.__decorate || function(e, t, o, n) {
    var i, r = arguments.length, a = r < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, o) : n;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) a = Reflect.decorate(e, t, o, n); else for (var s = e.length - 1; 0 <= s; s--) (i = e[s]) && (a = (r < 3 ? i(a) : 3 < r ? i(t, o, a) : i(t, o)) || a);
    return 3 < r && a && Object.defineProperty(t, o, a), a;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("Global"), s = e("AudioManager"), c = e("GameConfig"), l = e("GameData"), d = e("UIManager"), u = e("WebManager"), p = cc._decorator, h = p.ccclass, f = p.property, g = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.moneyLabel = null, e.diamondLabel = null, e.pieceLabel = null, e.profitLabel = null, 
        e.isSpeed = !1, e;
    }
    return i(e, t), e.prototype.onLoad = function() {
        d.default.getInstance().barViews.push(this);
    }, e.prototype.onDestroy = function() {
        var e = d.default.getInstance().barViews.indexOf(this);
        -1 < e && d.default.getInstance().barViews.splice(e, 1);
    }, e.prototype.onClickDiamond = function() {
        s.default.getInstance().playAudio("按钮2"), u.default.getInstance().sentLog("点击钻石栏按键"), 
        r.G.platform != r.Platform.XiaoDu ? d.default.getInstance().loadPopPnl("diamond", {
            num: 100,
            view: this
        }) : d.default.getInstance().showToast({
            str: "今日获取钻石次数已达上限"
        });
    }, e.prototype.onClickPiece = function() {
        s.default.getInstance().playAudio("按钮2"), u.default.getInstance().sentLog("点击碎片栏按键"), 
        u.default.getInstance().sentLog("触发碎片不足"), l.GD.pieceCount < c.GC.maxPieceCount && r.G.platform != r.Platform.XiaoDu ? d.default.getInstance().loadPopPnl("piece", {
            num: c.GC.pieceNum,
            view: this
        }) : d.default.getInstance().showToast({
            str: "今日获取碎片次数已达上限"
        });
    }, e.prototype.start = function() {
        var e = this;
        this.load(Date.now()), this.refresh(), this.schedule(function() {
            e.load(Date.now());
        }, 1), this.schedule(this.refresh, 5);
    }, e.prototype.refresh = function() {
        0 < r.G.profit && (cc.Tween.stopAllByTarget(this.moneyLabel.node), this.moneyLabel.node.scale = 1, 
        cc.tween(this.moneyLabel.node).to(.2, {
            scale: 1.2
        }).to(.2, {
            scale: 1
        }).start()), this.moneyLabel.string = GA.formatNumber(l.GD.money), this.diamondLabel.string = GA.formatNumber(l.GD.diamond), 
        this.pieceLabel.string = GA.formatNumber(l.GD.piece), this.isSpeed ? this.profitLabel.string = GA.formatNumber(5 * r.G.profit) + "/秒" : this.profitLabel.string = GA.formatNumber(r.G.profit) + "/秒";
    }, e.prototype.speedUp = function(e) {
        void 0 === e && (e = 60), this.isSpeed || (this.isSpeed = !0, l.GD.speedTime = Date.now() + 1e3 * e, 
        this.unschedule(this.refresh), this.refresh(), this.schedule(this.refresh, 1));
    }, e.prototype.speedDown = function() {
        this.isSpeed && (this.isSpeed = !1, this.unschedule(this.refresh), this.refresh(), 
        this.schedule(this.refresh, 5));
    }, e.prototype.load = function(e) {
        var t, o;
        0 == l.GD.moneyLastTime && (l.GD.moneyLastTime = Date.now()), l.GD.speedTime > e ? this.speedUp() : this.speedDown(), 
        l.GD.moneyLastTime < e && (t = Math.floor((e - l.GD.moneyLastTime) / 1e3), o = Math.min(7200, t), 
        l.GD.speedTime > e ? l.GD.updateNumber("money", o * r.G.profit * 2) : l.GD.speedTime > l.GD.moneyLastTime ? (e = Math.floor((l.GD.speedTime - l.GD.moneyLastTime) / 1e3), 
        l.GD.updateNumber("money", e * r.G.profit * 2 + (o - e) * r.G.profit)) : l.GD.updateNumber("money", o * r.G.profit), 
        l.GD.moneyLastTime += 1e3 * t);
    }, a([ f(cc.Label) ], e.prototype, "moneyLabel", void 0), a([ f(cc.Label) ], e.prototype, "diamondLabel", void 0), 
    a([ f(cc.Label) ], e.prototype, "pieceLabel", void 0), a([ f(cc.Label) ], e.prototype, "profitLabel", void 0), 
    a([ h ], e);
}(cc.Component);

n.default = g;